<?php
    set_include_path("/fs1/WWW-library-ext");
    include_once "includes/functions.php";
    
    if ($_GET['type']=="rel") {
        if ((is_numeric($_GET['id1'])) and (is_numeric($_GET['id2']))) {
            // if type is not, or very, inc/decrement value of relationship (value must decrease by 2 to include this user's visit)
            if ($_GET['rating']=="very") {
                @mysql_query("UPDATE `resource_relationships` SET value=value+1 WHERE origin_id={$_GET['id2']} AND destination_id={$_GET['id1']} LIMIT 1");
            }
            else if ($_GET['rating']=="not") {
                @mysql_query("UPDATE `resource_relationships` SET value=value-2 WHERE origin_id={$_GET['id2']} AND destination_id={$_GET['id1']} LIMIT 1");
            }
            else if ($_GET['rating']=="somewhat") {
                #do nothing
                //@mysql_query("UPDATE `resource_relationships` SET value=value-1 WHERE origin_id={$_GET['id2']} AND destination_id={$_GET['id1']} LIMIT 1");
            }
        }
    }
    else if ($_GET['type']=="search") {
        if ((is_numeric($_GET['id1'])) and (is_numeric($_GET['id2']))) {
            // if type is not, or very, inc/decrement value of relationship (value must decrease by 2 to include this user's visit)
            if ($_GET['rating']=="very") {
                @mysql_query("UPDATE `resource_search_relationships` SET value=value+1 WHERE search_id={$_GET['id2']} AND resource_id={$_GET['id1']} LIMIT 1");
            }
            else if ($_GET['rating']=="not") {
                @mysql_query("UPDATE `resource_search_relationships` SET value=value-2 WHERE search_id={$_GET['id2']} AND resource_id={$_GET['id1']} LIMIT 1");
            }
            else if ($_GET['rating']=="somewhat") {
                #do nothing.
                //@mysql_query("UPDATE `resource_search_relationships` SET value=value-1 WHERE search_id={$_GET['id2']} AND resource_id={$_GET['id1']} LIMIT 1");
            }
        }
    }
    @mysql_close();
?>